package com.tom.architect.party4.day34.simple;


import com.tom.architect.party4.day34.retrofit.Retrofit;

import okhttp3.OkHttpClient;

public class RetrofitClient {
    private final static ServiceApi mServiceApi;

    static {
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                // 拦截器打印。
//                .addInterceptor(new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
//                    @Override
//                    public void log(String message) {
//                        Log.e("TAG", message);
//                    }
//                }).setLever(HttpLoggingInterceptor.Level.BODY))
                .build();

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://www.api.com/httpServer/")
//                .addConverterFactory(GsonConverterFactory.create()) // 添加解析转换工厂gson解析。
                .client(okHttpClient)
                .build();

        // 用代理创建实例。ServiceApi接口--> 实例对象
        mServiceApi = retrofit.create(ServiceApi.class);
    }

    public static ServiceApi getServiceApi() {
        return mServiceApi;
    }


}

